using System.Text.RegularExpressions;
using Framework.Library.Core.Utils.Miscellaneous;

namespace Framework.Library.Core.Utils.Text
{
    public static class RegexUtils
    {
        public static string ToRegexPattern(string wildcardSearch)
        {
            ValidationUtils.ArgumentNotNull(wildcardSearch, "wildcardSearch");

            string regexPattern = Regex.Escape(wildcardSearch);

            regexPattern = regexPattern.Replace(@"\*", ".*?");
            regexPattern = regexPattern.Replace(@"\?", ".");

            return regexPattern;
        }

        public static string StripHtml(string html, bool allowHarmlessTags)
        {
            if (string.IsNullOrEmpty(html))
                return string.Empty;

            if (allowHarmlessTags)
                return Regex.Replace(html, "", string.Empty);

            return Regex.Replace(html, "<[^>]*>", string.Empty);
        }
    }
}